adding required packages
library(ggmap)
## Loading required package: ggplot2
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────────────── tidyverse 1.2.1 ──
## âś” tibble 1.4.2 âś” purrr 0.2.4
## âś” tidyr 0.8.0 âś” dplyr 0.7.4
## âś” readr 1.1.1 âś” stringr 1.2.0
## âś” tibble 1.4.2 âś” forcats 0.2.0
## ── Conflicts ────────────────────────────────────────────────── tidyverse_conflicts() ──
## âś– dplyr::filter() masks stats::filter()
## âś– dplyr::lag() masks stats::lag()
library(maps)
##
## Attaching package: 'maps'
## The following object is masked from 'package:purrr':
##
## map
library(mapproj)
map.1 <- get_map(location = c(-4.5413, 50.82435), zoom = 14, maptype = "roadmap")
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=50.82435,-4.5413&zoom=14&size=640x640&scale=2&maptype=roadmap&language=en-EN&sensor=false
ggmap(map.1)
map.2 <- get_map(location = c(-4.5413, 50.82435), zoom = 14, maptype = "watercolor")
## maptype = "watercolor" is only available with source = "stamen".
## resetting to source = "stamen"...
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=50.82435,-4.5413&zoom=14&size=640x640&scale=2&maptype=terrain&sensor=false
## Map from URL : http://tile.stamen.com/watercolor/14/7984/5496.jpg
## Map from URL : http://tile.stamen.com/watercolor/14/7985/5496.jpg
## Map from URL : http://tile.stamen.com/watercolor/14/7986/5496.jpg
## Map from URL : http://tile.stamen.com/watercolor/14/7984/5497.jpg
## Map from URL : http://tile.stamen.com/watercolor/14/7985/5497.jpg
## Map from URL : http://tile.stamen.com/watercolor/14/7986/5497.jpg
## Map from URL : http://tile.stamen.com/watercolor/14/7984/5498.jpg
## Map from URL : http://tile.stamen.com/watercolor/14/7985/5498.jpg
## Map from URL : http://tile.stamen.com/watercolor/14/7986/5498.jpg
ggmap(map.2)
Key: red- Bude North Cornwall Cricket Club blue- Crooklets Beach green- Summerleaze Beach yellow- Crooklets Inn (pub)
ggmap(map.1) +
geom_point(
aes(x = -4.552577 , y = 50.83386),
color = "red", size = 3) +
geom_point(
aes(x = -4.553923 , y = 50.83613),
color = "blue", size = 3) +
geom_point(
aes(x = -4.551326 , y = 50.83099),
color = "green", size = 3)+
geom_point(
aes(x = -4.551132, y = 50.83597),
color = "yellow", size = 3)
ggmap(map.2) +
geom_point(
aes(x = -4.552577 , y = 50.83386),
color = "red", size = 3) +
geom_point(
aes(x = -4.553923 , y = 50.83613),
color = "blue", size = 3) +
geom_point(
aes(x = -4.551326 , y = 50.83099),
color = "green", size = 3)+
geom_point(
aes(x = -4.551132, y = 50.83597),
color = "yellow", size = 3)
from <- "Crooklets Inn"
to <- "Bude North Cornwall Cricket Club"
route_df <- route(from, to, structure = "route")
## Information from URL : http://maps.googleapis.com/maps/api/directions/json?origin=Crooklets+Inn&destination=Bude+North+Cornwall+Cricket+Club&mode=driving&units=metric&alternatives=false&sensor=false
ggmap(map.1) +
geom_path(
aes(x = lon, y = lat), colour = "red", size = 1.5,
data = route_df, lineend = "round"
)
from <- "Crooklet's Inn"
to <- "Bude North Cornwall Cricket Club"
route_df <- route(from, to, structure = "route")
## Information from URL : http://maps.googleapis.com/maps/api/directions/json?origin=Crooklet's+Inn&destination=Bude+North+Cornwall+Cricket+Club&mode=driving&units=metric&alternatives=false&sensor=false
ggmap(map.2) +
geom_path(
aes(x = lon, y = lat), colour = "red", size = 1.5,
data = route_df, lineend = "round"
)